package com.graduation.project.controller.group;

import com.graduation.project.entity.dto.AddGroupDTO;
import com.graduation.project.entity.dto.AllotDefenseDTO;
import com.graduation.project.service.group.DefenseService;
import com.graduation.project.utils.ResultUtil;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/defense")
public class DefenseController {

    @Autowired
    private DefenseService defenseService;

    /**
     * 新增分组
     */
    @PostMapping("/post/addGroup")
    public ResultUtil<?> addGroup(@RequestBody AddGroupDTO addGroupDTO) {
        return defenseService.addGroup(addGroupDTO);
    }

    /**
     * 查询分组
     */
    @GetMapping("/get/listDefenseGroup")
    public ResultUtil<?> listDefenseGroup() {
        return defenseService.listDefenseGroup();
    }

    /**
     * 修改组名
     */
    @GetMapping("/put/updateGroupName/{groupCode}/{groupName}")
    public ResultUtil<?> updateGroupName(@PathVariable("groupCode") String groupCode, @PathVariable("groupName") String groupName) {
        return defenseService.updateGroupName(groupCode, groupName);
    }

    /**
     * 获取下拉课题数据
     */
    @GetMapping("/get/listFinalizeOptions/{groupCode}")
    public ResultUtil<?> listFinalizeOptions(@PathVariable("groupCode") String groupCode) {
        return defenseService.listFinalizeOptions(groupCode);
    }

    /**
     * 获取本小组已有的课题
     */
    @GetMapping("/get/listMySelfFinalize/{groupCode}")
    public ResultUtil<?> listMySelfFinalize(@PathVariable("groupCode") String groupCode) {
        return defenseService.listMySelfFinalize(groupCode);
    }

    /**
     * 分配答辩小组
     */
    @PutMapping("/put/allotDefense")
    public ResultUtil<?> allotDefense(@RequestBody AllotDefenseDTO allotDefenseDTO) {
        return defenseService.allotDefense(allotDefenseDTO);
    }

    /**
     * 删除分组
     */
    @GetMapping("/delete/deleteGroup/{groupCode}")
    public ResultUtil<?> deleteGroup(@PathVariable("groupCode") String groupCode) {
        return defenseService.deleteGroup(groupCode);
    }

}
